const { exec, escape} = require('../data/mysql')
const {genPassword} = require('../util/cryp')

const login = (username, password) => {
    //用户正确
   username = escape(username)
   
   // console.log(username,password)

    //生成加密密码
    // password = genPassword(password)
    password = escape(password)
    const sql = `select username,realname from users where username = ${username} and password = ${password};`
    return exec(sql).then(list => {
        //console.log(list[0])
        return list[0] || {}
    })
    // if(username === '1' && password === '1') {
    //     return true
    // }
    // return false
}
module.exports = {
    login,
}